﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenSoftStore.Client.Common;

namespace OpenSoftStore.Client.UIL.ManageReport
{
    public partial class ReportList : UserControl
    {
        private static ReportList instance;

        public ReportList()
        {
            InitializeComponent();
            this.Dock = DockStyle.Fill;
            tvReport.ExpandAll();
            tvReport.SelectedNode = tvReport.Nodes[0];
            SPACommon.SetTreeStyle(tvReport);

            pnlReport.Controls.Clear();
            pnlReport.Controls.Add(ReportDefault.Instance);
            ReportDefault.Instance.Dock = DockStyle.Fill;

            if (!SysPowerManager.IsHavePower(SysPowerManager.开单统计))
            {
                tvReport.Nodes["报表主页"].Nodes["运营相关"].Nodes["开单统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.消费排行))
            {
                tvReport.Nodes["报表主页"].Nodes["客户相关"].Nodes["消费排行"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.套餐剩余计次项统计))
            {
                tvReport.Nodes["报表主页"].Nodes["运营相关"].Nodes["套餐剩余计次项统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.套餐退办统计))
            {
                tvReport.Nodes["报表主页"].Nodes["运营相关"].Nodes["套餐退办统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.客户消费喜好统计))
            {
                tvReport.Nodes["报表主页"].Nodes["客户相关"].Nodes["客户消费喜好统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.商品_项目销售统计))
            {
                tvReport.Nodes["报表主页"].Nodes["运营相关"].Nodes["商品_服务销售统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.人员提成统计))
            {
                tvReport.Nodes["报表主页"].Nodes["运营相关"].Nodes["商品_人员提成统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.客户欠款_还款统计))
            {
                tvReport.Nodes["报表主页"].Nodes["客户相关"].Nodes["客户欠款_还款统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.充值统计))
            {
                tvReport.Nodes["报表主页"].Nodes["运营相关"].Nodes["充值统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.套餐办理统计))
            {
                tvReport.Nodes["报表主页"].Nodes["运营相关"].Nodes["套餐办理统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.近期没消费客户统计))
            {
                tvReport.Nodes["报表主页"].Nodes["客户相关"].Nodes["近期没消费客户统计"].Remove();
            }
            if (!SysPowerManager.IsHavePower(SysPowerManager.客户增长情况统计))
            {
                tvReport.Nodes["报表主页"].Nodes["客户相关"].Nodes["客户增长统计"].Remove();
            }
            //if (!SysPowerManager.IsHavePower(SysPowerManager.积分排行))
            //{
            //    tvReport.Nodes["报表主页"].Nodes["客户相关"].Nodes["积分排行"].Remove();
            //}
            if (!SysPowerManager.IsHavePower(SysPowerManager.库存进出情况统计))
            {
                tvReport.Nodes["报表主页"].Nodes["库存相关"].Nodes["库存进出情况统计"].Remove();
            }
        }

        public static ReportList Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ReportList();
                }
                return instance;
            }
        }


        private void tvReport_AfterSelect(object sender, TreeViewEventArgs e)
        {
            var node = tvReport.SelectedNode;
            switch (node.Text)
            {
                case "报表主页":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportDefault.Instance);
                    ReportDefault.Instance.Dock = DockStyle.Fill;
                    break;
                case "客户开单情况":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportBill.Instance);
                    ReportBill.Instance.Dock = DockStyle.Fill;
                    break;
                case "产品使用情况":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportProduct.Instance);
                    ReportProduct.Instance.Dock = DockStyle.Fill;
                    break;
                case "开单统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportBill.Instance);
                    ReportBill.Instance.Dock = DockStyle.Fill;
                    break;
                case "套餐办理统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportDinnerSale.Instance);
                    ReportDinnerSale.Instance.Dock = DockStyle.Fill;
                    break;
                case "套餐退办统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportDinnerSaleBack.Instance);
                    ReportDinnerSaleBack.Instance.Dock = DockStyle.Fill;
                    break;
                case "充值统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportValueRecord.Instance);
                    ReportValueRecord.Instance.Dock = DockStyle.Fill;
                    break;
                case "商品/服务销售统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportProduct.Instance);
                    ReportProduct.Instance.Dock = DockStyle.Fill;
                    break;
                case "套餐剩余计次项统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportDinnerTimes.Instance);
                    ReportDinnerTimes.Instance.Dock = DockStyle.Fill;
                    break;
                case "客户欠款/还款统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportReturnMoney.Instance);
                    ReportReturnMoney.Instance.Dock = DockStyle.Fill;
                    break;
                case "消费排行":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportMemberSale.Instance);
                    ReportMemberSale.Instance.Dock = DockStyle.Fill;
                    break;
                case "客户消费喜好统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportMemberProductSale.Instance);
                    ReportMemberProductSale.Instance.Dock = DockStyle.Fill;
                    break;
                case "客户增长统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportMemberAdd.Instance);
                    ReportMemberAdd.Instance.Dock = DockStyle.Fill;
                    break;
                case "近期没消费客户统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportMemberActivity.Instance);
                    ReportMemberActivity.Instance.Dock = DockStyle.Fill;
                    break;
                case "收支情况":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportMoney.Instance);
                    ReportMoney.Instance.Dock = DockStyle.Fill;
                    break;
                case "工作日报表":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(WorkReportByDay.Instance);
                    WorkReportByDay.Instance.Dock = DockStyle.Fill;
                    break;
                case "人员提成统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportBorakerage.Instance);
                    ReportBorakerage.Instance.Dock = DockStyle.Fill;
                    break;
                case "库存进出情况统计":
                    pnlReport.Controls.Clear();
                    pnlReport.Controls.Add(ReportStoreIO.Instance);
                    ReportStoreIO.Instance.Dock = DockStyle.Fill;
                    break;
            }
        }

    }
}
